package main

import (
	"fmt"
	"sync"
	"time"
)

type Singleton struct {
}

var (
	mu       sync.Mutex
	instance *Singleton
)

func getInstance() *Singleton {
	defer wg.Done()
	if nil == instance {
		mu.Lock()
		defer mu.Unlock()
		if nil == instance {
			fmt.Println("init")
			time.Sleep(time.Second)
			instance = &Singleton{}
		}
	}
	return instance
}
